package domain.model;

public class Code implements iCode {
	private String code = null;
	private RekenFuncties calc = new RekenFuncties();
	
	public Code()
	{
		this.generateCode();
	}

	@Override
	public String getCode() {
		return this.code;
	}

	private void setcode(String code) {
		this.code = code;

	}

	private void generateCode() {
		int random = 0;
		String code = "";
		for (int i = 0; i <= 15 ; i++){
			random = calc.generateRandom(34, 0);
			code += codeer(random);
		}
		this.setcode(code);

	}
	
	private String codeer(int getal){
		String[] codex = {"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
		
		return codex[getal];
	}

	

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((code == null) ? 0 : code.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Code other = (Code) obj;
		if (code == null) {
			if (other.code != null)
				return false;
		} else if (!code.equals(other.code))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "code=" + code ;
	}
	

}
